package home.my.base.service;

import home.my.base.dao.BaseDao;
import home.my.base.model.BaseObj;
import home.my.base.sql.AbsCondition;
import home.my.base.sql.ConditionQuery;
import home.my.base.util.downloader.DownLoader;
import home.my.recordmanage.util.GlobalParameters;

import java.io.Serializable;
import java.util.List;

public abstract class BaseService<T extends BaseObj> implements GlobalParameters{
	private BaseDao<T> dao;
	
	public T get(Serializable id){
		return dao.get(id);
	}
	
	public T load(Serializable id){
		return dao.load(id);
	}
	
	public Long create(T entity){
		return dao.create(entity);
	}
	
	public void update(T entity){
		dao.update(entity);
	}
	
	public void delete(T entity){
		dao.delete(entity);
	}

	public List<T> find(ConditionQuery q,boolean needInit){
		return dao.find(q,needInit);
	}
	
	public List<T> find(String orders,boolean needInit,AbsCondition... c){
		return dao.find(orders,needInit,c);
	}
	
	public List<T> find(String orders,boolean needInit){
		return dao.find(orders,needInit);
	}
	
	public void export(ConditionQuery q,DownLoader<T> downLoader){
		dao.export(q, downLoader);
	}

	public BaseDao<T> getDao() {
		return dao;
	}

	public void setDao(BaseDao<T> dao) {
		this.dao = dao;
	}
	
}
